const HtmlWebpackPlugin = require("html-webpack-plugin");
const { resolve } = require("path");
 
 
 module.exports = {
     entry:'./src/index.js',
     output:{
         filename:'built.js',
         path:resolve(__dirname,'build'),
     },
     module:{
         rules:[
             /**
              * 语法检查：eslint-loader eslint
              * 注意：只检查源代码，第三方库不检查
              * 设置检查规则：package.json中eslintConfig中设置
              * airbnb : eslint-config-airbnb-base eslint eslint-plugin-import
              */
             {
                 test:/\.js$/,
                 exclude:/node_modules/,
                 loader:'eslint-loader',
                 options:{
                        //自动修复eslint错误
                        fix:true
                 }
             }
         ]
     },
     plugins:[
         new HtmlWebpackPlugin({
             template:'./src/index.html'
         })
     ],
     mode:'development',
     devServer:{
         static : {directory: resolve(__dirname,'build')},
         watchFiles:['./src/index.html'],
         //启动gzip压缩
         compress:true,
         port:3000,
         //自动打开默认浏览器
         open:true
     }
 }